using System.Collections;
using System.Collections.Generic;
using Main.Event;
using Main.Inventory;
using Main.Item;
using UnityEngine;
using ZSW.Framework;

namespace Main
{
    public class PickUp : ZSWF_InitMonoBehaviour
    {
        private BaseItem baseItem;
        private void OnTriggerEnter2D(Collider2D other)
        {
            if (other.TryGetComponent(out baseItem))
            {
                if (baseItem.ItemDetails.CanPickUp)
                {
                    if (ZSWF_IOCContainer.Get<InventoryManager>().TryAddItemToBag(baseItem.ItemID))
                    {
                        Destroy(baseItem.gameObject);

                        MainEventSystem.CallPlaySoundEvent(SoundName.Pickup);
                    }

                }
            }
        }

        private void OnTriggerExit2D(Collider2D other)
        {

        }
    }
}